package be;

import java.util.ArrayList;


public class Table {
	
	private class Var{
		String type;
		String name;
		public Var(String type,String name){
			this.type = type;
			this.name = name;
		}
		public String toString(){
			return name + " " + type;
		}
		
	}
	
	public ArrayList<Var> table;
	
	
	public String getVars(){
		StringBuilder sb = new StringBuilder();
		
		for(Var tmp : table)
			sb.append(tmp.toString()+",");
		
		return sb.substring(0, sb.length()-1);
		
	}
	
	public Table(){
		table = new ArrayList<Var>();
	}

	public void addVariable(String name, String type){
		if(type.toLowerCase().trim().equals("int")){
			addInt(name);
		}
		else if(type.toLowerCase().trim().equals("varchar")){
			addVarchar(name, 50);
		}
		else if(type.toLowerCase().trim().equals("float")){
			addFloat(name);
		}else if(type.toLowerCase().trim().equals("date")){
			addDate(name);
		}
	}
	
	public void addInt(String name){
		table.add(new Var("int",name));
	}
	public void addDate(String name){
		table.add(new Var("date",name));
	}
	public void addVarchar(String name,int length){
		table.add(new Var("varchar("+ length + ")",name));
	}
	public void addFloat(String name){
		table.add(new Var("float",name));
	}
}
